
<!-- saved from url=(0037)http://c.tsz90.com/home/register.html -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="viewport" content="width=device-width, initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">

    <title>注册</title>
    <link href="__PUBLIC__/static/css/login/reset_5.css" rel="stylesheet" type="text/css">
    <link href="__PUBLIC__/static/css/login/style.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" href="__PUBLIC__/static/css/login/new_style.css">
    <link rel="stylesheet" href="__PUBLIC__/static/css/login/font-awesome.min.css">

    <script type="text/javascript" src="__PUBLIC__/static/js/login/jquery.min.js"></script>
    <!-- 弹出层 -->
    <link rel="stylesheet" href="__PUBLIC__/static/css/login/dialog.css">
    <script src="__PUBLIC__/static/js/login/zepto.min.js"></script>
    <script src="__PUBLIC__/static/js/login/dialog.js"></script>
    <!-- 弹出层 -->
    <script type="text/javascript" src="__PUBLIC__/static/js/login/global.js"></script>
</head>
<body>
<style>
    .site-header .tit-name {
        overflow: initial;
    }
    #tomial {
        width: 100%;
        height: 30px;
        color: #fff;
        font-size: 14px;
        background-color: #4a90fc;
        pointer-events: initial;
        border: none;
        border-radius: 3px;
        outline: none;
        -webkit-appearance: none;
    }
</style>

<div class="site-header registerTitle">
    <a href="http://c.tsz90.com/home.html" class="back"></a>
    <div class="tit-name"><img src="__PUBLIC__/static/upload/login/80359afde5db74c1f7366ad555b06e76.png"></div>
</div>
<div class="main-cont">
    <div class="main registerMain">
        <div class="member-tab">
            <ul class="m_tab_tit">
                <li class="active libg" style="width:100%;">
                    <a style="color:#666;">免费注册</a>
                </li>
            </ul>
        </div>
        <div class="denglu-box">
            <form id="register_form">
                <div class="dl-form">
                    <div class="item-box">
                        <input id="username" name="username" placeholder="手机号" type="text" class="m_txt">
                    </div>
                    <div class="item-box" style="display: none;">
                        <input name="email" placeholder="邮箱，可用于找回密码" type="email" class="m_txt">
                    </div>
                    <div class="item-box">
                        <input name="password" type="password" class="m_txt" placeholder="输入密码" id="password">
                    </div>
                    <div class="item-box">
                        <input name="password_confirm" type="password" class="m_txt" placeholder="确认密码">
                    </div>
                    <div class="item-box">
                        <input type="text" class="m_txt" placeholder="输入验证码" id="captcha" name="captcha">
                        <div class="yzm">
                            <canvas id="canvas" width="100" height="30"></canvas>
                        </div>
                    </div>
                    <div class="item-box">
                        <input id="verification" name="verification" class="button1 active m_txt" placeholder="请输入短信验证码" required="">
                        <div class="yzm">
                            <button type="button" id="tomial" class="btn btn-primary text-center">发送验证码</button>
                        </div>
                    </div>
                </div>
                <input type="hidden" name="parent_uid" value="0">
            </form>
        </div>
    </div>
    <div class="member-btn">
        <input type="button" id="btn" class="button1 active js-register" value="确认注册">
    </div>
</div>
<script type="text/javascript">
    $(function () {
        //确认注册
        $('.js-register').click(function () {
            $.post(
                window.location.href,
                $('#register_form').serialize(),
                function(res) {
                    $('.yzm img').click();
                    message(res.message,res.redirect,res.type);
                },'json'
            );
        });

        //回车登录
        $(document).keyup(function(event){
            if(event.keyCode ==13){
                $('.js-register').click();
            }
        });

        // $('#tomial').click(function(){
        //     var mobile = $("#username").val();
        //     var partten = /^1[3-9]\d{9}$/;
        //     if(!partten.test(mobile)){
        //         message('请输入正确的手机号','','error');
        //         return false;
        //     }
        //
        //     var validate = $.trim($("#captcha").val());
        //     if(validate == '') {
        //         message('请输入验证码','','error');
        //         return false;
        //     }
        //
        //     $("#tomial").attr("disabled", true);
        //
        //     var data = {
        //         type: 2,
        //         mobile: mobile,
        //         validate: validate
        //     };
        //     Common.ApiPost("/home/register/sendsmscode", data, function (res) {
        //         if(res.type != "success"){
        //             $('.yzm img').click();
        //             $("#tomial").attr("disabled", false);
        //             message(res.message,res.redirect,res.type);
        //             return;
        //         }
        //         new invokeSettime("#tomial");
        //     }, function (res) {
        //         $('.yzm img').click();
        //         $("#tomial").attr("disabled", false);
        //         message(res.message,res.redirect,res.type);
        //     });
        // });
    });

    function invokeSettime(obj){
        var countdown=60;
        settime(obj);
        function settime(obj) {
            if (countdown == 0) {
                $(obj).attr("disabled",false);
                $(obj).text("获取验证码");
                countdown = 60;
                return;
            } else {
                $(obj).attr("disabled",true);
                $(obj).text("(" + countdown + ") s 重发");
                countdown--;
            }
            setTimeout(function() {
                    settime(obj) }
                ,1000)
        }
    }
</script>
<!--//验证码！！！-->
<script>
    var time = 60;
    $("#tomial").click(function () {
        var tel=$("#username").val();
        // var _that=$(this);
        // vat t=setInterval(function(){
        //     if(time>0){
        //         _this.val(time+"秒后重新发送");
        //         _this.attr("disabled",true);
        //         time--;
        //     }else{
        //         _this.val("重新发送");
        //         _this.attr("disabled",false);
        //         clearInterval(t);
        //         time=60;
        //     }
        // },1000);
        $.ajax({
            url:"{:url('login/note')}",
            type:'post',
            data:{tel:tel},
            dataType:'json',
            success:function(e){
                console.log(e);
            }
        })
    })
    $(function(){
        var show_num = [];
        draw(show_num);
        $("#canvas").on('click',function(){
            draw(show_num);
        })
        $("#btn").on('click',function(){
            var val = $("#captcha").val().toLowerCase();
            var num = show_num.join("");
            if(val==''){
                alert('请输入验证码！');
                draw(show_num);
                return false;
            }else if(val == num){
                draw(show_num);
                $("#captcha").val('');
            }else{
                alert('验证码错误！请重新输入！');
                draw(show_num);
                $("#captcha").val('');
                return false;
                // draw(show_num);
            }

            var tel=$("#username").val();
            var password=$("#password").val();
            var code=$("#verification").val();
            $.ajax({
                url:"{:url('login/zhuce_do')}",
                type:'post',
                data:{tel:tel,password:password,code:code},
                dataType:'json',
                success:function (e) {
                    console.log(e)
                }
            })
        })
    })
    //生成并渲染出验证码图形
    function draw(show_num) {
        var canvas_width=$('#canvas').width();
        var canvas_height=$('#canvas').height();
        var canvas = document.getElementById("canvas");//获取到canvas的对象，演员
        var context = canvas.getContext("2d");//获取到canvas画图的环境，演员表演的舞台
        canvas.width = canvas_width;
        canvas.height = canvas_height;
        var sCode = "a,b,c,d,e,f,g,h,i,j,k,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,E,F,G,H,J,K,L,M,N,P,Q,R,S,T,W,X,Y,Z,1,2,3,4,5,6,7,8,9,0";
        var aCode = sCode.split(",");
        var aLength = aCode.length;//获取到数组的长度
        for (var i = 0; i < 4; i++) { //这里的for循环可以控制验证码位数（如果想显示6位数，4改成6即可）
            var j = Math.floor(Math.random() * aLength);//获取到随机的索引值
            // var deg = Math.random() * 30 * Math.PI / 180;//产生0~30之间的随机弧度
            var deg = Math.random() - 0.5; //产生一个随机弧度
            var txt = aCode[j];//得到随机的一个内容
            show_num[i] = txt.toLowerCase();
            var x = 10 + i * 20;//文字在canvas上的x坐标
            var y = 20 + Math.random() * 8;//文字在canvas上的y坐标
            context.font = "bold 23px 微软雅黑";
            context.translate(x, y);
            context.rotate(deg);
            context.fillStyle = randomColor();
            context.fillText(txt, 0, 0);
            context.rotate(-deg);
            context.translate(-x, -y);
        }
        for (var i = 0; i <= 5; i++) { //验证码上显示线条
            context.strokeStyle = randomColor();
            context.beginPath();
            context.moveTo(Math.random() * canvas_width, Math.random() * canvas_height);
            context.lineTo(Math.random() * canvas_width, Math.random() * canvas_height);
            context.stroke();
        }
        for (var i = 0; i <= 30; i++) { //验证码上显示小点
            context.strokeStyle = randomColor();
            context.beginPath();
            var x = Math.random() * canvas_width;
            var y = Math.random() * canvas_height;
            context.moveTo(x, y);
            context.lineTo(x + 1, y + 1);
            context.stroke();
        }
    }
    //得到随机的颜色值
    function randomColor() {
        var r = Math.floor(Math.random() * 256);
        var g = Math.floor(Math.random() * 256);
        var b = Math.floor(Math.random() * 256);
        return "rgb(" + r + "," + g + "," + b + ")";
    }
</script>
</body></html>